package com.util;

import java.io.*;
import java.util.Enumeration;
import java.util.Properties;

public class ReadConfig {
	public static void main(String args[]) {

		/*Properties pps = new Properties();
		try {
			pps.load(new FileInputStream("config.ini"));
			Enumeration enum1 = pps.propertyNames();
			while (enum1.hasMoreElements()) {
				String strKey = (String) enum1.nextElement();
				String strValue = pps.getProperty(strKey);
				System.out.println(strKey + "=" + strValue);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}*/
		ReadConfig rcf=new ReadConfig();
		System.out.println( rcf.readValue("config.ini","url.freeav"));
		
	}
	
	/**
	 * 
	 * @param configfile
	 * @param key
	 * @return value
	 */
	public static String readValue(String configfile,String key){
		
		Properties props = new Properties();
		try {
			InputStream in = new BufferedInputStream(new FileInputStream(configfile));
			props.load(in);
			String value = props.getProperty(key);
			return value;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}   
		
	}

}
